<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <meta name="renderer" content="webkit" />
    <title>积分兑换记录</title>
    <meta name="force-rendering" content="webkit" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
    <meta name="viewport"
        content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <link rel="stylesheet" href="css/shop.css">
    <link rel="stylesheet" href="css/weui.min.css">
    <link rel="stylesheet" href="css/jquery-weui.min.css">
    <script src="js/jquery-2.1.4.js"></script>
    <script src="js/jquery-weui.js"></script>
    <script src="wxJs/utils/contain.js"></script>
    <script src="wxJs/utils/storage.js"></script>
    <style>
        .order-title {
            padding: 0 15px;
            line-height: 40px;
            font-size: 14px;
            background-color: #f1f1f2;
            font-weight: 400;
        }

        .order-item {
            border-bottom: 1px solid #EBEDEF;
            padding: 10px 15px;
            background: #fff;
            align-items: center;
        }

        .top-info {
            font-size: 14px;
            font-weight: 400;
            line-height: 24px;
            color: #999
        }

        .top-info .name {
            color: #333;
            font-size: 14px;
            font-weight: bold;
        }

        .order-item .cl-main {
            font-weight: bold;
        }

        .btm-info {
            color: #999
        }

        .image-contain {
            width: 48px;
            height: 48px;
            flex-shrink: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            text-align: center;
            margin-right: 10px;
            align-content: center;
            border-radius: 50%;
            border-radius: 50%;
            background: linear-gradient(-45deg, #3978fe, #76a2ff);
            color: #fff;
            font-size: 24px;
            box-shadow: 0 0 4px #3978fe;
        }
    </style>
</head>

<body>
    <div class="header">
        <a class="haader-left" href="javascript:window.history.go(-1)"><i class="iconfont icon-left"></i></a>
        <div class="haader-content">积分兑换记录</div>
        <div class="haader-right">
            <i class="iconfont icon-riqi"></i>&nbsp;
        </div>
    </div>
    <div id="exchangeLog">

    </div>

</body>
<script>
    $(".icon-riqi").picker({
        onClose: function (obj) {
            var year = parseInt(obj.value[0])
            var month = parseInt(obj.value[1])
            if (month < 10) {
                month = "0" + month
            }
            var selectMonth = year + "-" + month;


            queryExchangeLog(selectMonth)
        },
        title: "请选择年月",
        cols: [{
            textAlign: 'center',
            values: (function () {
                var arr = [], cur = new Date();
                for (var i = 2019; i <= cur.getFullYear(); i++) {
                    arr.push(i + "年")
                }
                return arr
            })()
            //如果你希望显示文案和实际值不同，可以在这里加一个: [.....]
        },
            {
                textAlign: 'center',
                values: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月",]
            }
        ]
    });


    var userId = GetQueryString("userId");
    if (!userId) {
        window.history.back(-1);
    }else {
        var date = new Date(), y = date.getFullYear(), m = date.getMonth() + 1;
        if (m < 10) {
            m = "0" + m
        }
        var nowMonth = y + "-" + m
        queryExchangeLog(nowMonth)    //查询当前月记录
    }

    /*查询用户兑换积分记录*/
    function queryExchangeLog(month) {
        $.post(getWeiContextPath() + "/wx/VipUser/queryExchangeLog", {
            wxUserId: userId,
            month: month
        }, function (res) {

            if (res.code == 0) {
                var _exchangeLog = $('#exchangeLog').empty()
                $.each(res.data,function (i, obj) {
                    _exchangeLog.append('<div class="order-item flex" >\n' +
                        '            <div class="image-contain  iconfont icon-jifen"></div>\n' +
                        '            <div class="flex column">\n' +
                        '                <div class="flex between top-info">\n' +
                        '                    <div class="name">兑换'+obj.exchangeJf+'积分</div>\n' +
                        '                    <div class="cl-main">￥'+obj.exchageMoney+'</div>\n' +
                        '                </div>\n' +
                        '                <div class="flex between btm-info">\n' +
                        '                    <div>'+obj.createTime+'</div>\n' +
                        '                    <div>兑换成功</div>\n' +
                        '                </div>\n' +
                        '            </div>\n' +
                        '        </div>')
                })
            } else {
                window.location.href = "index.html?infrom=1"
            }
        })
    }

</script>
</html>